using System;

namespace KexpScrobbler.Kexp
{
    public class SongInformation
    {
        public SongInformation(string title, string album, string artist, string label,
            int? releaseYear, string dj, string show, DateTime startTime)
        {
            Title = title;
            Album = album;
            Artist = artist;
            StartTime = startTime;
            Label = label;
            ReleaseYear = releaseYear;
            Dj = dj;
            Show = show;
        }

        public static bool operator ==(SongInformation a, SongInformation b)
        {
            try
            {
                return a.Album == b.Album && a.Artist == b.Artist && a.Title == b.Title;
            }
            catch
            {
                return false;
            }
        }

        public static bool operator !=(SongInformation a, SongInformation b)
        {
            return !(a == b);
        }

        public override string ToString()
        {
            return String.Format("Artist: {0}; Title: {1}; Album: {2}; Label: {3}", Artist, Title, Album, Label);
        }

        public override bool Equals(object obj)
        {
            SongInformation b = obj as SongInformation;

            if (b == null)
            {
                return false;
            }

            return b == this;
        }

        public override int GetHashCode()
        {
            if (string.IsNullOrEmpty(Artist) || string.IsNullOrEmpty(Title) || string.IsNullOrEmpty(Album))
            {
                return 0;
            }

            return Artist[0] + 10 * Title[0] + 100 * Album[0];
        }

        public DateTime StartTime
        {
            get;
            set;
        }

        public string Title
        {
            get;
            set;
        }

        public string Artist
        {
            get;
            set;
        }

        public string Album
        {
            get;
            set;
        }

        public string Label
        {
            get;
            set;
        }

        public int? ReleaseYear
        {
            get;
            set;
        }

        public string Dj
        {
            get;
            set;
        }

        public string Show
        {
            get;
            set;
        }
    }
}
